import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TBossRefresh } from "../../../Message/Db/Tables/TBossRefresh";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class BossRefreshConfig
    
    export  class BossRefreshConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (BossRefreshConfig._instance) 
            {
                throw new Error("BossRefreshConfig is single");
            }
            this.init();
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_boss_refresh.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TBossRefresh();
                loc1.id = loc2.id;
                loc1.mapId = loc2.mapId;
                loc1.plan = loc2.plan;
                loc1.code = loc2.code;
                loc1.refreshCount = loc2.refreshCount;
                loc1.distance = loc2.distance;
                loc1.interval = loc2.interval;
                loc1.byPoint = loc2.byPoint;
                loc1.direction = loc2.direction;
                loc1.ring = loc2.ring;
                loc1.route = StringHelper.getString(loc2.route);
                this._map[loc1.id] = loc1;
            }
            return;
        }

        public getInfoByCode(arg1: int): TBossRefresh
        {
            return this._map[arg1];
        }

        public getInfoByMapPlan(arg1: int, arg2: int): Array<any>
        {
            var loc1=null;
            if (this._infoByMapPlan) 
            {
                this._infoByMapPlan.splice(0);
            }
            else 
            {
                this._infoByMapPlan = [];
            }
            var loc2=0;
            var loc3=this._map;
            for(loc1 of loc3) 
            {
                if (!(loc1.mapId == arg1 && loc1.plan == arg2)) 
                {
                    continue;
                }
                this._infoByMapPlan.push(loc1);
            }
            return this._infoByMapPlan;
        }

        public getInfoByBossCode(arg1: int): Array<any>
        {
            var loc1=null;
            if (this._infoByBossCode) 
            {
                this._infoByBossCode.splice(0);
            }
            else 
            {
                this._infoByBossCode = [];
            }
            var loc2=0;
            var loc3=this._map;
            for(loc1 of loc3) 
            {
                if (loc1.code != arg1) 
                {
                    continue;
                }
                this._infoByBossCode.push(loc1);
            }
            return this._infoByBossCode;
        }

        public static get instance(): BossRefreshConfig
        {
            if (!BossRefreshConfig._instance) 
            {
                BossRefreshConfig._instance = new BossRefreshConfig();
            }
            return BossRefreshConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_infoByMapPlan: Array<any>;

        /* internal */ /* var */_infoByBossCode: Array<any>;

        /* internal */ static /* var */_instance: BossRefreshConfig;
    }
